/*
 ============================================================================
 Name		: StrLightSettingView.cpp
 Author	  : 
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CStrLightSettingView implementation
 ============================================================================
 */
#include <aknviewappui.h>
#include "StrLightSettingView.h"
#include "LemonAssistant.hrh"
#include <LemonAssistant.rsg>

CStrLightSettingView::CStrLightSettingView()
	{
	// No implementation required
	iContainer = NULL;
	}

CStrLightSettingView::~CStrLightSettingView()
	{
	DoDeactivate();
	}

CStrLightSettingView* CStrLightSettingView::NewLC()
	{
	CStrLightSettingView* self = new (ELeave) CStrLightSettingView();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CStrLightSettingView* CStrLightSettingView::NewL()
	{
	CStrLightSettingView* self = CStrLightSettingView::NewLC();
	CleanupStack::Pop(); // self;
	return self;
	}

void CStrLightSettingView::ConstructL()
	{
	BaseConstructL(R_STRAIGHT_LIGHT_SETTINGS_VIEW);
	}

TUid CStrLightSettingView::Id() const
	{
	return TUid::Uid(ELemonAssistantAppViewStrLightSetting);
	}

void CStrLightSettingView::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case ECommandSettingChange:
			iContainer->EditItemL(0, ETrue);
			break;
		default:
			AppUi()->HandleCommandL(aCommand);
		}
	}

void CStrLightSettingView::HandleStatusPaneSizeChange()
	{
	if (iContainer != NULL)
		iContainer->SetRect(ClientRect());
	}

/**
 * 
 * */
void CStrLightSettingView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
		TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
	{
	if (iContainer == NULL)
		{
		iContainer = CStrLightSettingList::NewL();

		iContainer->SetMopParent(this);
		iContainer->ConstructFromResourceL(R_STRAIGHT_LIGHT_SETTING_ITEM_LIST);
		AppUi()->AddToStackL(*this, iContainer);

		iContainer->MakeVisible(ETrue);
		iContainer->SetRect(ClientRect());
		iContainer->ActivateL();

		//add your init code ...

		}
	}
void CStrLightSettingView::DoDeactivate()
	{
	if (iContainer != NULL)
		{
		AppUi()->RemoveFromViewStack(*this, iContainer);
		delete iContainer;
		iContainer = NULL;
		}
	}
